import { Body, Controller, Get, Post } from '@nestjs/common';
import RoleService from '../service/role.service';
import R from 'libs/common/utils/R';
import CreateRoleDto from '../dto/CreateRoleDto';

@Controller('/role')
export default class RoleController {
  constructor(private readonly roleService: RoleService) {}

  @Post('/create')
  async create(@Body() createRoleDto: CreateRoleDto): Promise<R<any>> {
    await this.roleService.create(createRoleDto);
    return R.ok();
  }

  @Post('/getRoleByRoleIds')
  async getRoleByRoleIds(@Body('roleIds') roleIds: string[]): Promise<R<any>> {
    let res = await this.roleService.getRoleByRoleIds(roleIds);
    return R.ok(res);
  }

  @Post('/getRoleByKey')
  async getRoleByKey(@Body('roleKey') roleKey: string): Promise<R<any>> {
    const res = await this.roleService.getRoleByKey(roleKey);
    return R.ok(res);
  }

  @Post('/getRoleById')
  async getRoleById(@Body('roleId') roleId: string): Promise<R<any>> {
    const res = await this.roleService.getRoleById(roleId);
    return R.ok(res);
  }
  
}
